<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="custom" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
    <title>员工列表</title>
</head>

<body>
<div class="pageheader">
    <h2>员工列表</h2>
</div>
<div class="contentpanel">
    <form class="form-inline">
        <div class="btn-group mr10">
            <input type="text" class="form-control " name="name" value="${listDto.name}"
                   placeholder="员工姓名">
            <select class="form-control" name="gender">
                <option value="">性别</option>
                <option value="1" ${listDto.gender eq "1"?"selected":""}>男</option>
                <option value="0" ${listDto.gender eq "2"?"selected":""}>女</option>
                <option value="2" ${listDto.gender eq "0"?"selected":""}>未知</option>
            </select>
            <input type="text" class="form-control " name="phone" value="${listDto.phone}"
                   placeholder="手机号码">
            <input type="text" class="form-control " name="dept" value="${listDto.dept}"
                   placeholder="部门名称">
            <button type="submit" class="form-control btn-success">查询</button>
        </div>
        <div class="btn-group mr10">
            <a href="${contextPath}/admin/organization/employee/edit.htm" class="btn btn-primary"
               type="button">
                <i class="fa fa-pencil mr5"></i>添加员工
            </a>
        </div>
    </form>

    <table class="table table-striped dataTable no-footer" id="table2" role="grid" aria-describedby="table2_info">
        <thead>
        <tr role="row">
            <th class="sorting_asc" tabindex="0" aria-controls="table2"
                rowspan="1" colspan="1" aria-sort="ascending">
                姓名
            </th>
            <th class="sorting_asc" tabindex="0" aria-controls="table2"
                rowspan="1" colspan="1" aria-sort="ascending">
                性别
            </th>
            <th class="sorting_asc" tabindex="0" aria-controls="table2"
                rowspan="1" colspan="1" aria-sort="ascending">
                年龄
            </th>
            <th class="sorting_asc" tabindex="0" aria-controls="table2"
                rowspan="1" colspan="1" aria-sort="ascending">
                电话
            </th>
            <th class="sorting_asc" tabindex="0" aria-controls="table2"
                rowspan="1" colspan="1" aria-sort="ascending">
                微信昵称
            </th>
            <th class="sorting_asc" tabindex="0" aria-controls="table2"
                rowspan="1" colspan="1" aria-sort="ascending">
                所属部门
            </th>
            <th class="sorting_asc" tabindex="0" aria-controls="table2"
                rowspan="1" colspan="1" aria-sort="ascending">
                分派人员
            </th>
            <th class="sorting_asc" tabindex="0" aria-controls="table2"
                rowspan="1" colspan="1" aria-sort="ascending">
                社区监督人员
            </th>
            <th class="sorting_asc" tabindex="0" aria-controls="table2"
                rowspan="1" colspan="1" aria-sort="ascending">
                创建时间
            </th>
            <th class="sorting" tabindex="0" aria-controls="table2" rowspan="1" colspan="1">
                操作
            </th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${listDto.list}" var="item" varStatus="status">
            <tr class="gradeA ${status.index/2 eq 0?"odd":"even"}">
                <td>
                        ${item.name}
                </td>
                <td>
                    <c:if test="${item.gender== '1'}">男</c:if>
                    <c:if test="${item.gender== '2'}">女</c:if>
                    <c:if test="${item.gender== '0'}">未知</c:if>
                </td>
                <td>
                        ${item.age}
                </td>
                <td>
                        ${item.phone}
                </td>
                <td>
                    <c:forEach items="${item.nickNameList}" var="nickname">
                        <span class="label label-primary">${nickname}</span>
                    </c:forEach>
                </td>
                <td>
                        ${item.deptDto.name}
                </td>
                <td>
                    <c:if test="${ not item.leader}">
                        <span class="label label-info">否</span>
                    </c:if>
                    <c:if test="${item.leader}">
                        <span class="label label-success">是</span>
                    </c:if>
                </td>
                <td>
                    <c:if test="${ not item.inspector}">
                        <span class="label label-info">否</span>
                    </c:if>
                    <c:if test="${item.inspector}">
                        <span class="label label-success">是</span>
                    </c:if>
                </td>
                <td>
                    <span class="label label-default">${item.createDateTime}</span>
                </td>
                <td>
                    <form action="${contextPath}/admin/organization/employee/delete.htm"
                          method="post">
                        <input type="hidden" name="uuid" value="${item.uuid}">
                        <button class="deleteBtn hide" type="submit"
                                onclick="javascript:return confirm('确定删除员工[${item.name}]吗?');">
                            删除
                        </button>

                        <div class="btn-group mr5">
                            <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
                                操作 <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu" role="menu">
                                <li>
                                    <a href="${contextPath}/admin/organization/employee/edit.htm?uuid=${item.uuid}">编辑</a>
                                </li>

                                <shiro:hasPermission name="ORGANIZATION_ACCOUNT_LIST:*">
                                    <li>
                                        <a href="${contextPath}/admin/organization/account/list.htm?employeeUuid=${item.uuid}">账号列表</a>
                                    </li>
                                </shiro:hasPermission>
                                <li>
                                    <a href="${contextPath}/admin/organization/employee/bind_member.htm?employeeUuid=${item.uuid}">绑定微信</a>
                                </li>
                                <li>
                                    <a href="#" class="loadModal"
                                       url="${contextPath}/admin/organization/employee/relieve_member?employeeUuid=${item.uuid}"
                                       data-toggle="modal"
                                       data-target="#myModal">解绑微信</a></li>
                                </li>
                                <li>
                                    <a href="#" class="delete">删除</a>
                                </li>
                            </ul>
                        </div>
                    </form>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <custom:page page="${listDto}"/>
    <script type="text/javascript">
        <c:if test="${not empty param.edit}">

        jQuery.gritter.add({
            title: '新增/编辑 成功!',
            class_name: "growl-success",
            sticky: false
        });

        </c:if>
        <c:if test="${not empty param.delete}">
        jQuery.gritter.add({
            title: '删除 成功!',
            class_name: "growl-success",
            sticky: false
        });
        </c:if>
        <c:if test="${not empty param.bind}">
        jQuery.gritter.add({
            title: '绑定 成功',
            class_name: "growl-success",
            sticky: false
        });
        </c:if>
        <c:if test="${not empty param.relieve}">
        jQuery.gritter.add({
            title: '解除绑定 成功',
            class_name: "growl-success",
            sticky: false
        });
        </c:if>
    </script>
</div>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">

        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>
<script src="${contextPath}/resources/js/jquery.datatables.min.js"></script>
<script type="text/javascript">
    jQuery(document).ready(function () {
        jQuery('#table2').dataTable({
            "bPaginate": false,// 分页按钮
            "bFilter": false,// 搜索栏
            "bLengthChange": false,// 每行显示记录数
            "bInfo": false
        });
    });
    $("body").on("click", ".loadModal", function () {
        var url = $(this).attr("url");
        $(".modal-content").load(url);
    });
    $(function () {
        $(".delete").click(function () {
            $(this).parents("td").find(".deleteBtn").trigger('click');
        });
    })
</script>
</body>
</html>
